#ifndef _LQSLIB_H_
#define _LQSLIB_H_

#define DEBUG 

/*************************list***********************/
typedef struct _cel_link_node {
	void *value;
	struct _cel_link_node *prev;
	struct _cel_link_node *next;
}cel_link_node_t;

typedef struct {
	unsigned int size;
	cel_link_node_t *head;
	cel_link_node_t *tail;
}cel_link_t;

typedef int (*cel_compare_fn_t)(void *, void *);
typedef int (*cel_release_callback_fn_t)(void *);

unsigned int cel_link_size(cel_link_t *link);
cel_link_t *new_cel_link(void);
void free_cel_link(cel_link_t **link, cel_release_callback_fn_t relfunc);

void cel_link_add_first(cel_link_t *link, void *value);
void cel_link_add_last(cel_link_t *link, void *value);
void cel_link_insert(cel_link_t *link, unsigned int idx, void *value);

void *cel_link_remove_first(cel_link_t *link);
void *cel_link_remove_last(cel_link_t *link);
void *cel_link_remove(cel_link_t *link, unsigned int idx);
void *cel_link_remove_obj(cel_link_t *link, void *value, cel_compare_fn_t comp);

void *cel_link_get(cel_link_t *link, unsigned int idx);
void *cel_link_set(cel_link_t *link, unsigned int idx, void *value);
void *cel_link_set_obj(cel_link_t *link, void *search, void *value, cel_compare_fn_t comp);

/*************************queue**********************/
typedef cel_link_t cel_queue_t;

extern inline cel_queue_t *new_cel_queue(void);
extern inline void free_cel_queue(cel_queue_t **queue, cel_release_callback_fn_t relfunc);
extern inline unsigned int cel_queue_length(cel_queue_t *queue);
extern inline void cel_queue_en(cel_queue_t *queue, void *value);
extern inline void *cel_queue_de(cel_queue_t *queue);


/*************************stack**********************/
typedef cel_link_t cel_stack_t;

extern inline cel_stack_t *new_cel_stack(void);
extern void free_cel_stack(cel_stack_t **stack, cel_release_callback_fn_t relfunc);
extern unsigned int cel_stack_depth(cel_stack_t *stack);
extern void cel_stack_push(cel_stack_t *stack, void *value);
extern void *cel_stack_pop(cel_stack_t *stack);


#endif //_LQSLIB_H_
